import java.util.Random;
import java.util.Scanner;

public class aa {
    public static void main(String[] args) {
//        int r =  getCount();
//        int r2 =  getCount2();
//        System.out.println(r);
//        System.out.println("r2" + r2);
//        shuixianhua();
//        sanjiaoxing();
//        chengfabiao();
//        breakDemo();
//        continueDemo();
//        continueDemo();
//        randomTest();
        randomTest2();
    }
    
    
    public static void randomTest2() {
            /*
        需求: 实现猜数字小游戏

        1. 使用Random产生一个 1~100 之间的随机数  ---> randomNumber
        2. 使用Scanner从键盘录入用户猜的数据 ---> scNumber
        3. 比对
     */

        Random random = new Random();;
        Scanner sc  = new Scanner(System.in);
        int ranInt =   random.nextInt(1000);
//        System.out.println(ranInt);

        boolean flag = true;

        while (flag ){
            int nInt = sc.nextInt();
            if(nInt> ranInt){
                System.out.println("错了,输入的值大于随机数");
            }else if(nInt < ranInt){
                System.out.println("错了,输入的值小于随机数");
            }else{
                flag = false;
            }
        }
        System.out.println("你猜对了");


    }   
    public static void randomTest() {
        // 2. 召唤精灵
        Random r = new Random();

        for (int i = 1; i <= 2000; i++) {
            // 3. 指挥精灵产生随机数
            int num = r.nextInt(100) +1;
            if(num<=1)System.out.println(num);
        }

        System.out.println("-----------------------");

        // 需求: 产生20~80之间的随机数
//        for (int i = 1; i <= 20; i++) {
//            int num = r.nextInt(61) + 20;
//            System.out.println(num);
//        }


    }
    public static void  breakDemo(){
        for (int i = 0; i < 5; i++) {
            if(i==3){
                break;
            }
            System.out.println(i);
        }
    }
    public static void  continueDemo(){
        for (int i = 0; i < 5; i++) {
            if(i==3){
                continue;
            }
            System.out.println(i);
        }
    }
    public  static void chengfabiao(){
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j+"*"+i+"="+(i*j)+"   ");
            }
            System.out.println();

        }
    }

    public static  void sanjiaoxing(){
        for (int i = 0; i < 5; i++) {
            int flag = i;
            for (int j = 0; j < 5-i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static int getCount(){
        int res=0;
        for(int i = 0;i <=100;i++){
            if(i%2==0){
                res+=i;
            }
        }
        System.out.println(res);
        return res;
    }
    public  static int getCount2(){
        int res = 0;
        for (int i = 0; i <= 100; i+=2) {
            res+=i;
        }
        System.out.println(res);
        return  res;
    }


    public static void shuixianhua(){
        for (int i = 0; i < 5; i++) {
            int num  = 0;
            System.out.println(i);
        }
//        System.out.println(num);
    }

}
